﻿using Castle.Core.Logging;
using RabbitMQ.Client;
using System;
using System.Configuration;
using System.Text;
using Yto.Common.Dependency;
using Yto.Threading;
using Yto.Threading.BackgroundWorkers;

namespace com.ytocargo.Application.MqJobs
{
    public class MqJobManager : TimedBgdWorker, IMqJobManager, ISingleton
    {
        private readonly ICtnManager _ctnManager;
        private ILogger _logger;

        public MqJobManager(BaseTimer baseTimer,
            ICtnManager ctnManager)
            : base(baseTimer)
        {
            JobPeriod = int.TryParse(ConfigurationManager.AppSettings["MqSendPeriod"], out int tempValue)
                        ? tempValue : 20000;

            baseTimer.Period = JobPeriod;

            _ctnManager = ctnManager;
            _logger = _ctnManager.IsRegisted<ILoggerFactory>() ?
                _ctnManager.Resolver<ILoggerFactory>().Create(typeof(MqJobManager))
                : NullLogger.Instance;

        }
        protected override void DoWork()
        {
            
        }

        public int JobPeriod { get; private set; }
    }
}
